package Internet;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

//翻译服务器，翻译客户端发来的信息
public class UDPTranslateServer extends UDPEchoServer{

    private HashMap<String, String> translateHashMap = new HashMap<>();

    public UDPTranslateServer(int port) throws SocketException {
        super(port);

        translateHashMap.put("cat", "猫");
        translateHashMap.put("dog", "狗");
        translateHashMap.put("sheep", "羊");

    }

    @Override
    public String process(String request) {
        return translateHashMap.getOrDefault(request, "未找到该译文");
    }

    public static void main(String[] args) throws IOException {
        UDPTranslateServer udpTranslateServer = new UDPTranslateServer(9090);
        udpTranslateServer.start();
    }
}
